package liuyuyang.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import liuyuyang.domain.Student;
import liuyuyang.pojo.Result;
import liuyuyang.service.StudentService;
import liuyuyang.vo.StudentVo;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RestController
@RequestMapping("/student")
public class StudentController {
    @Resource
    private StudentService studentService;

    @PostMapping
    public Result<String> editOradd(@RequestBody Student student) {
        return Result.success(studentService.editOradd(student));
    }

    @DeleteMapping("/{id}")
    public Result<String> del(@PathVariable Integer id) {
        return Result.success(studentService.del(id));
    }

    @GetMapping("/{id}")
    public Result<Student> get(@PathVariable Integer id) {
        return Result.success(studentService.get(id));
    }

    @PostMapping("/{num}/{size}")
    public Result<Page<Student>> condition(@RequestBody StudentVo studentVo, @PathVariable Integer num, @PathVariable Integer size) {
        return Result.success(studentService.list(studentVo, num, size));
    }

    @GetMapping
    public String Test(){
        return "Hello World!";
    }
}
